<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 24] 24.39 java.io.ObjectInputStream (JDK 1.1)</TITLE>
<META NAME="author" CONTENT="David Flanagan">
<META NAME="date" CONTENT="Thu Jul 31 16:22:29 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java in a Nutshell">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java in a Nutshell" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch24_38.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 24<br>The java.io Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch24_40.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JNUT2-CH-24-SECT-39">24.39 java.io.ObjectInputStream (JDK 1.1)</A></h2>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-24-SECT-39.1"></A></h3>
</DIV>

<P CLASS=para>
<tt CLASS=literal>ObjectInputStream</tt> is used to deserialize objects,
arrays, and other values from a stream that was previously
created with an <tt CLASS=literal>ObjectOutputStream</tt>.  The
<tt CLASS=literal>readObject()</tt> method deserializes objects and arrays
(which should then be cast to the appropriate type);
various other methods are used to read primitive data values
from the stream.  Note that only objects that implement the
<tt CLASS=literal>Serializable</tt> interface or the <tt CLASS=literal>Externalizable</tt>
interface can be serialized and deserialized.

<P CLASS=para>
The <tt CLASS=literal>defaultReadObject()</tt> method may only be called
from the <tt CLASS=literal>readObject()</tt> method of an object that is
currently being deserialized.  It allows an object to
perform additional processing after deserializing itself.
The <tt CLASS=literal>registerValidation()</tt> method may also only be
called from the <tt CLASS=literal>readObject()</tt> method of an object
being deserialized.  It registers an
<tt CLASS=literal>ObjectInputValidation</tt> object (typically the object
being deserialized) to be notified when a complete tree of
objects has been deserialized and the original call to the
<tt CLASS=literal>readObject()</tt> method of the <tt CLASS=literal>ObjectInputStream</tt>
is about to return to its caller.

<P CLASS=para>
The remaining methods include miscellaneous stream manipulation
methods and several protected methods for use by subclasses
that want to customize the deserialization behavior of
<tt CLASS=literal>ObjectInputStream</tt>.

<DIV CLASS=screen>
<P>
<PRE>
public class <tt CLASS=literal>ObjectInputStream</tt> extends InputStream implements ObjectInput {
    // <tt CLASS=literal>Public Constructor</tt>
            public <tt CLASS=literal>ObjectInputStream</tt>(InputStream <tt CLASS=literal>in</tt>) throws IOException, StreamCorruptedException;
    // <tt CLASS=literal>Public Instance Methods</tt>
            public int <tt CLASS=literal>available</tt>() throws IOException;  //<tt CLASS=literal> Overrides InputStream</tt>
            public void <tt CLASS=literal>close</tt>() throws IOException;  //<tt CLASS=literal> Overrides InputStream</tt>
            public final void <tt CLASS=literal>defaultReadObject</tt>() throws IOException, ClassNotFoundException, NotActiveException;
            public int <tt CLASS=literal>read</tt>() throws IOException;  //<tt CLASS=literal> Defines InputStream</tt>
            public int <tt CLASS=literal>read</tt>(byte[] <tt CLASS=literal>data</tt>, int <tt CLASS=literal>offset</tt>, int <tt CLASS=literal>length</tt>) throws IOException;  //<tt CLASS=literal> Overrides InputStream</tt>
            public boolean <tt CLASS=literal>readBoolean</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public byte <tt CLASS=literal>readByte</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public char <tt CLASS=literal>readChar</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public double <tt CLASS=literal>readDouble</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public float <tt CLASS=literal>readFloat</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public void <tt CLASS=literal>readFully</tt>(byte[] <tt CLASS=literal>data</tt>) throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public void <tt CLASS=literal>readFully</tt>(byte[] <tt CLASS=literal>data</tt>, int <tt CLASS=literal>offset</tt>, int <tt CLASS=literal>size</tt>) throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public int <tt CLASS=literal>readInt</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public String <tt CLASS=literal>readLine</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public long <tt CLASS=literal>readLong</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public final Object <tt CLASS=literal>readObject</tt>() throws OptionalDataException,
            public final Object <tt CLASS=literal>readObject</tt>() 'u'ClassNotFoundException, IOException;  //<tt CLASS=literal> From ObjectInput</tt>
            public short <tt CLASS=literal>readShort</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public String <tt CLASS=literal>readUTF</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public int <tt CLASS=literal>readUnsignedByte</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public int <tt CLASS=literal>readUnsignedShort</tt>() throws IOException;  //<tt CLASS=literal> From DataInput</tt>
            public synchronized void <tt CLASS=literal>registerValidation</tt>(ObjectInputValidation <tt CLASS=literal>obj</tt>, int <tt CLASS=literal>prio</tt>)
            public synchronized void <tt CLASS=literal>registerValidation</tt>'u'throws NotActiveException, InvalidObjectException;
            public int <tt CLASS=literal>skipBytes</tt>(int <tt CLASS=literal>len</tt>) throws IOException;  //<tt CLASS=literal> From DataInput</tt>
    // <tt CLASS=literal>Protected Instance Methods</tt>
            protected final boolean <tt CLASS=literal>enableResolveObject</tt>(boolean <tt CLASS=literal>enable</tt>) throws SecurityException;
            protected void <tt CLASS=literal>readStreamHeader</tt>() throws IOException, StreamCorruptedException;
            protected Class <tt CLASS=literal>resolveClass</tt>(ObjectStreamClass <tt CLASS=literal>v</tt>) throws IOException, ClassNotFoundException;
            protected Object <tt CLASS=literal>resolveObject</tt>(Object <tt CLASS=literal>obj</tt>) throws IOException;
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-24-SECT-39.2">Hierarchy:</A></h3>

<P CLASS=para>
Object->InputStream->ObjectInputStream(ObjectInput(DataInput))

</DIV>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch24_38.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch24_40.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>java.io.ObjectInput (JDK 1.1)</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>java.io.ObjectInputValidation (JDK 1.1)</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
